package com.app.base.adapter;

import java.util.List;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class CommonViewPageAdapter extends FragmentPagerAdapter {

	private String[] pageTitles;
	private List<Fragment> mFragmentList;

	public CommonViewPageAdapter(FragmentManager fm) {
		super(fm);
	}

	public void setPageTitles(String[] pageTitles) {
		this.pageTitles = pageTitles;
	}

	public void setData(List<Fragment> mFragmentList) {
		this.mFragmentList = mFragmentList;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {

		if (mFragmentList == null) {
			return 0;
		}
		return mFragmentList.size();
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return pageTitles[position];

	}

	@Override
	public Fragment getItem(int arg0) {
		return mFragmentList.get(arg0);
	}
}
